package model;

import us.codecraft.webmagic.model.annotation.ExtractBy;
import us.codecraft.webmagic.model.annotation.TargetUrl;

import java.util.Date;
import java.util.List;

/**
 * Created by zhangcheng on 2017/4/21 0021.
 */
@TargetUrl({"https://my.oschina.net/flashsword/blog/\\d+"})
public class OschinaBlogModel {
    @ExtractBy("//title/text()")
    private String title;
    @ExtractBy(
            value = "//*[@id=\"blogBody\"]/div[2]/tidyText()",
            type = ExtractBy.Type.XPath
    )
    private String content;
    @ExtractBy(
            value = "//*[@id=\"classify\"]/a/text()",
            multi = true
    )
    private List<String> tags;
    @ExtractBy("//div[@class=\'BlogStat\']/regex(\'\\d+-\\d+-\\d+\\s+\\d+:\\d+\')")
    private Date date;

    public String getTitle() {
        return this.title;
    }

    public String getContent() {
        return this.content;
    }

    public List<String> getTags() {
        return this.tags;
    }

    public Date getDate() {
        return this.date;
    }

    @Override
    public String toString(){
        return this.title +"    "+this.content+"    "+this.tags+"    "+this.date;
    }

}
